#include<iostream>
#include<string>

using namespace std;

int main(){
	string s;
	cin>>s;
	
	int ans = 0;
    int leftCount = 0;
    for (auto &c : s) {
        if (c == '(') {
            leftCount++;
        } else {
            if (leftCount > 0) {
                leftCount--;
            } else {
                ans++;
            }
        }
    }
    ans += leftCount;
	cout<<ans;
    return 0;
} 
